<extend name="Public/base" />
<block name="content">
<div id="content">
	<div id="content-header">
		<div id="breadcrumb">
			<a class="tip-bottom" href="{:U('Index/index')}" data-original-title="首页"><i class="icon-home"></i> 首页</a>
			<a class="tip-bottom" href="{:U('OnlineExpo/shopList')}" data-original-title="">{$meta_title_c}</a> 
			<a class="current" href="{$post_url}">{$meta_title}</a>
		</div>
	</div>
	<div class="container-fluid">
		<br/>
		<div class="row-fluid">
			<div class="span12">
				<div class="widget-box">
					<div class="widget-title">
						<span class="icon"> <i class="icon-align-justify"></i></span>
						<h5>{$meta_title}</h5>
					</div>
					<div class="widget-content nopadding">
						<form class="form-horizontal" method="post" action="">
						
							<div class="control-group">
								<label class="control-label">活 动:</label>
								<div class="controls">
									<select class="form-control span3" name="activity_id" id="activity_id" onchange="change_zone(activity_id)">
										<option value="0">选择活动</option>
										<volist name="activity_list" id="vo">
											<option value="{$vo.activity_id}">{$vo.activity_name|strip_tags}</option>
										</volist>
									</select>
								</div>
							</div>
							<div class="control-group">
								<label class="control-label">展 馆:</label>
								<div class="controls">
									<select class="form-control span3" name="zone_id" id="zone_id"  onchange="change_category(zone_id)">
										<option value="0">选择展馆</option>
										<volist name="zone_list" id="vo">
											<option value="{$vo.zone_id}">{$vo.zone_name|strip_tags}</option>
										</volist>
									</select>
								</div>
							</div>
							<div class="control-group">
								<label class="control-label">品 类:</label>
								<div class="controls">
									<select class="form-control span3" name="online_category_id" id="online_category_id">
										<option value="0">选择品类</option>
										<volist name="category_list" id="vo">
											<option value="{$vo.online_category_id}">{$vo.category_name|strip_tags}</option>
										</volist>
									</select>
								</div>
							</div>
						
							<div class="control-group">
								<label class="control-label">店铺名称:</label>
								<div class="controls">
									<input type="text" placeholder="店铺名称1-20个字符" class="ui-wizard-content span4" maxlength="20" name="online_shop_name" value="{$list.online_shop_name|htmlspecialchars}" >
								</div>
							</div>
							<div class="control-group">
								<label class="control-label">店铺位置:</label>
								<div class="controls">
									<input type="text" placeholder="店铺位置1-100个字符" class="ui-wizard-content span7" maxlength="100" name="online_shop_address" value="{$list.online_shop_address|htmlspecialchars}" >
								</div>
							</div>
							<div class="control-group">
								<label class="control-label">店铺政策:</label>
								<div class="controls">
									<textarea class="span7" maxlength="100" placeholder="店铺政策1-100个字符" name="online_shop_policy">{$list.online_shop_policy|htmlspecialchars}</textarea>
								</div>
							</div>
							<div class="control-group">
								<label class="control-label">排 序 :</label>
								<div class="controls">
									<input type="text" placeholder="排序为数字" class="ui-wizard-content span2" maxlength="5" name="sort" value='{$list.sort|htmlspecialchars}' >
								</div>
							</div>
							<div class="form-actions">
								<button class="btn btn-success" type="submit">提交</button>
							</div>
							<input type="hidden" name="online_shop_id" value="{$list.online_shop_id}"/>
							
						</form>
					</div>
				</div>
			</div>
		</div>
	</div>
</div>
<script type="text/javascript">

/**
 * @todo 活动展馆联动
 */
function change_zone(activity_id){
	var activity_id = parseInt($(activity_id).val());
	if(activity_id !== 0){
		$.post("{:U('OnlineExpo/getActivityZone')}",{activity_id : activity_id,data_type:1},function(backData){
			//商户选项
			$('#zone_id').empty();
			var option = '';
			option += '<option value="0">选择展馆</option>';
			if(backData.status == 1){
				$.each(backData.data,function(index,array){
					option += '<option value="'+array['zone_id']+'">'+array['zone_name']+'</option>';
				})
			}
			$('#zone_id').append(option);
			set_value("zone_id", 0);
			$('#online_category_id').empty();
			$('#online_category_id').append('<option value="0">选择品类</option>');
			set_value("online_category_id", 0);
		})
	}else{
		$('#zone_id').empty();
		$('#zone_id').append('<option value="0">选择展馆</option>');
		set_value("zone_id", 0);
		$('#online_category_id').empty();
		$('#online_category_id').append('<option value="0">选择品类</option>');
		set_value("online_category_id", 0);
	}
}

/**
 * @todo 展馆品类联动
 * @author sap
 */
function change_category(zone_id){
	var zone_id = parseInt($(zone_id).val());
	if(zone_id !== 0){
		$.post("{:U('OnlineExpo/getActivityZoneCategory')}",{zone_id : zone_id,data_type:1},function(backData){
			$('#online_category_id').empty();
			var option = '';
			option += '<option value="0">选择品类</option>';
			if(backData.status == 1){
				$.each(backData.data,function(index,array){
					option += '<option value="'+array['online_category_id']+'">'+array['category_name']+'</option>';
				})
			}
			$('#online_category_id').append(option);
			set_value("online_category_id", 0);
		})
	}else{
		$('#online_category_id').empty();
		$('#online_category_id').append('<option value="0">选择品类</option>');
		set_value("online_category_id", 0);
	}
}

$(document).ready(function(){
	
	set_value("activity_id", "{$list.activity_id|default=0}");
	set_value("zone_id", "{$list.zone_id|default=0}");
	set_value("online_category_id", "{$list.online_category_id|default=0}");
	
	$("form").submit(function(){
		//锁定登录按钮
		$('button').attr('disabled',true);
		var self = $(this);
		$.post("{$post_url}", self.serialize(), call_back, "json");
		return false;
		
		/**
		 * @todo 接收登录返回值
		 * @author PHP@妖孽 <dino_ma@163.com>
		 */
		function call_back(data){
			if(data.status==1){
				tke_alert(data.info,'alert-success');
				setTimeout(function(){
				  if (data.url) {
						location.href=data.url;
					}else{
						location.reload();
					}
				},1500);
			} else {
				$('button').attr('disabled',false);
				tke_alert(data.info,'alert-error');
			}
		}
	});
	//导航高亮
	highlight_subnav("{:U('OnlineExpo/shopList')}");
});
</script>
</block>